$(document).ready(function(){
	$.ajax({
		type: 'GET',
//		url地址 应该是servelet地址
		url: '../../HotSentimentServlet?method=getPublishedReportPage',
		data: {
			"pagenum":1
		},
		success:function(data){
			console.log(data);
		    var reports = JSON.parse(data).reports;
		    var recordsTotal =JSON.parse(data).recordsTotal;
		    $.each(reports,function(indexs,values){
		    	console.log(this.title);
		    	var id = this._id.$oid;
		    	var sentiment = "<a href=" + "\"../jsp/hotSentimentDetail.jsp" + "?id=" + id + "\""+ "class=\"list-group-item\">"
		    			+ "<h4 class=\"list-group-item-heading\">" + this.title +"</h4>"
		    			+ "<p class=\"list-group-item-text small holdspace\">监测时间段："+ this.beginDate + " 至 " +this.endDate + "</p>"
		    			+ "</a>";
		    	$("#SentimentTitle").append(sentiment);
		    	
//		    	var tr = $("<tr><td>"+this.user_id+"</td><td>"+this.username+"</td><td>"
//		    			+this.registered_date+"</td><td>"+this.role+"</td><td>"+this.status+"</td>"
//		    	+"<td class='center'>"
//            +"<button id='"+this.user_id+"_view' class='btn btn-success' >"
//                +"<i class='glyphicon glyphicon-zoom-in icon-white'></i>查看</button>&nbsp&nbsp"
//            +"<button id='"+this.user_id+"_edit' class='btn btn-info' >"
//                +"<i class='glyphicon glyphicon-edit icon-white'></i>修改</button>&nbsp&nbsp"
//            +"<button id='"+this.user_id+"_delete' class='btn btn-danger' >"
//                +"<i class='glyphicon glyphicon-trash icon-white'></i>删除</button></td>");
////		    	遍历添加行
//		    	$("#dailypublishTable").append(tr);
////		    	绑定查看按钮点击事件
//		    	var btnview_id =this.user_id+"_view";
//		    	$("#"+btnview_id).click(function(){
//			    		console.log(this.id);
//			    		viewDetail(this.id);
//		    	})
////		    	绑定编辑按钮点击事件
//		    	var btnedit_id =this.user_id+"_edit";
//		    	$("#"+btnedit_id).click(function(){
//			    		console.log(this.id);
//		    	})
//
////		    	绑定删除按钮点击事件		    	
//		    	var btndelete_id =this.user_id+"_delete";
//		    	$("#"+btndelete_id).click(function(){
//			    		console.log(this.id);
//		    	})


		    });
		    var url ="../../HotSentimentServlet?method=getPublishedReportPage";
		    pageMaker(recordsTotal,url,"pagetoolBar");

	    
		},
		error:function(){
			console.log("error");
		}
	})
	

	
	
//	查看按钮方法
//	function viewDetail(id){
//		var url = "../jsp/dailySentimentDetail.jsp";
//		location.href=url+"?id="+id;
//	}

	
	
/*	  $("#dailypublishTable").DataTable({

//		  指定要从哪个URL获取数据
		    	 "sAjaxSource":"../../Detection1.1/UserInfoServlet?method=GetUserList",
		    	 "sServerMethod":"GET",
//		    	 用于指定一屏显示的条数
		    	 "iDisplayLength" : 10,
//		    	 "bJQueryUI":true,	
//		    	 是否显示（使用）分页器
		    	 "bPaginate":true,
		    	 "pagingType": "simple_numbers",
//		    	 "dom": '<"top"i>rt<"bottom"flp><"clear">',
		    	 "dom": 'B<"clear">lfrtip',
		    	    "buttons": {
		    	        "name": 'primary',
		    	        "buttons": [ 'copy', 'csv', 'excel' ]
		    	    },
//		    	 指定当从服务端获取表格数据时，数据项使用的名字  default 'aaData'
		    	 "sAjaxDataProp":"users",
		    	 "aoColumns": [   {"mDataProp":"user_id","bVisible":false},
		    	                  {"mDataProp":"username"},
		    	                  {"mDataProp":"registered_date"},
		    	                  {"mDataProp":"role"},
		    	                  {"mDataProp":"status"}
		    	                  ],
//		    	                  没有数据时显示 如下内容
		    	 "sZeroRecords": "No records to display",
//		    	 以指定当正在处理数据的时候，是否显示“正在处理”这个提示信息
		    	 "bprocessing": true,
				 "bserverSide": true,
//				 用于指明当执行dataTable绑定时，是否返回DataTable对象
				 "bRetrieve":true,
//				 用于当要在同一个元素上执行新的dataTable绑定时，将之前的那个数据对象清除掉，换以新的对象设置
				 "bDestroy": true,
				 "buttons": [
				           { extend: '查看', editor: myEditor },
				           { extend: 'edit',   editor: myEditor },
				           { extend: 'remove', editor: myEditor }
				       ],
				 "buttons": [
				           {
				               extend: 'selectedSingle',
				               text: 'Log selected data',
				               action: function ( e, dt, button, config ) {
				                   console.log( dt.row( { selected: true } ).data() );
				               }
				           }
				       ],
				 "buttons": [ 'copy', 'csv', 'excel' ],
				//多语言配置
				  "oLanguage": {
	                    "sProcessing": "正在加载中......",
	                    "sLengthMenu": "每页显示 _MENU_ 条记录",
	                    "sZeroRecords": "对不起，查询不到相关数据！",
	                    "sEmptyTable": "表中无数据存在！",
	                    "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",
	                    "sInfoFiltered": "数据表中共为 _MAX_ 条记录",
	                    "sSearch": "搜索",
	                    "oPaginate": {
	                        "sFirst": "首页",
	                        "sPrevious": "上一页",
	                        "sNext": "下一页",
	                        "sLast": "末页"
	                    }
	                }, 
//				 是否让各列具有按列排序功能 bSort
				 "columns": [
				             { "users": "user_id"},
				             { "users": "username","bSort":true},
				             { "users": "registered_date" },
				             { "users": "role" },
				             { "users": "status" }
				         ],
				 "columnDefs": [
				                {
				                  "targets": [3],
				                  "data": "status",
				                  "render": function(data, type, full) {
//				                      return "<a href='/view?id=" + data + "'>Update</a>";
				                	  return "<span style='color:red;'>"+data+"</span>";
				                    }
				                  }
				               ]	      
			})*/
	
});